package com.dragon.repository.mapper;

import com.dragon.repository.entity.Menu;
import com.dragon.repository.entity.RoleMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 角色菜单表 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-06-12
 */
@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {

    /**
     * 获取菜单id集合
     * @param id
     * @return
     */
    @Select("SELECT N.menu_id AS id FROM " +
            "(SELECT B.id FROM dragon_admin_role A,dragon_role B WHERE A.admin_id = #{id} AND A.role_id = B.id)M,dragon_role_menu N " +
            "WHERE M.id = N.role_id")
    List<Menu> selectMenuSetById(Integer id);
}
